import { createRouter, createWebHashHistory } from 'vue-router';

const router = createRouter({
  history: createWebHashHistory(),
  scrollBehavior(to, from, savedPosition) {
    // 始终滚动到顶部
    return { top: 0 };
  },
  routes: [
    {
      path: '/',
      component: () => import('@/views/Layout/index.vue'),
      children: [
        {
          path: '/',
          component: () => import('@/views/home/index.vue'),
        },
        {
          path: '/Category/:id',
          component: () => import('@/views/Category/index.vue'),
        },
        {
          path: '/Category/sub/:id',
          component: () => import('@/views/cateSub/index.vue'),
        },
        {
          path: '/product/:id',
          component: () => import('@/views/Good/index.vue'),
        },
        {
          path: '/cart',
          component: () => import('@/views/cart/index.vue'),
        },
        {
          path: '/member/checkout',
          component: () => import('@/views/checkout/index.vue'),
        },
        {
          path: '/member/pay',
          component: () => import('@/views/Pay/index.vue'),
        },
        {
          path: '/member/pay/callback',
          component: () => import('@/views/Pay/callback.vue'),
        },
        {
          path: '/member',
          component: () => import('@/views/member/index.vue'),
          children: [
            {
              path: 'order',
              component: () => import('@/views/member/order.vue'),
            },
            {
              path: '/member',
              component: () => import('@/views/member/home.vue'),
            },
          ],
        },
      ],
    },
    {
      path: '/login',
      component: () => import('@/views/login/index.vue'),
    },
    {
      path: '/login/callback',
      component: () => import('@/views/login/callback.vue'),
    },
    {
      path: '/test',
      component: () => import('@/views/Test/index.vue'),
    },
  ],
});

export default router;
